package com.qvtu.web.utils;

import com.qvtu.web.domain.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

@Component
public class loginUtil {
    @Autowired
    HttpServletRequest request;
    public boolean isLogin(){
        Object loginUser = request.getSession().getAttribute("loginUser");
        System.out.println(loginUser);
        return loginUser!=null;
    }
    public Users getLoginUser() {
        Object loginUser = request.getSession().getAttribute("loginUser");
        if (loginUser instanceof Users) {
            return (Users) loginUser;
        }
        return null;
    }
}
